package com.geekaca.net712;

import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;


public class TestSend {

    public static void main(String[] args) {
        try (Socket socket = new Socket("127.0.0.1", 7894);
             // 打开输出流,向对方发送数据 Stream字节流
             OutputStream ops = socket.getOutputStream();
             // 包装一层
             DataOutputStream dos = new DataOutputStream(ops);) {

            dos.writeUTF("张三丰");
            dos.writeInt(109);
            dos.writeDouble(180.2);
            dos.flush();

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}